import share from 'kuan-utils/lib/wxShare'
import logo from '@/assets/logo.png'
import { isWechat, getWechatConfig } from './tools'

const defaultShare = {
  title: '没有标题', // 分享标题
  desc: '这里没有描述', // 分享描述
  link: window.location.href, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  imgUrl: logo // 分享图标
}

export default async (shareData = defaultShare) => {
  if (!isWechat) return
  const config = await getWechatConfig()
  share(shareData, config)
}
